package com.bwie.utils;

import io.jsonwebtoken.Jwts;
import org.springframework.stereotype.Component;

/**
 * @Author: 鑫仔
 * @Date: 2025/7/18 20:31
 * @Description:
 **/

public class TokenUtil {

    /**
     * @author: 鑫仔
     * @description: 获取用户Id
     * @params: [java.lang.String]
     * @return: java.lang.Integer
     * @date: 2025/7/18 20:32
     */
    public static Integer getUserId(String token) {
        Integer userId = Jwts.parser().setSigningKey("bwie").parseClaimsJws(token).getBody().get("id", Integer.class);
        return userId;
    }
    public static String getUserName(String token){
        String userName = Jwts.parser().setSigningKey("bwie").parseClaimsJws(token).getBody().get("userName", String.class);
        return userName;
    }
}
